package com.wj.blog.framework.enums;

/**
 * 响应状态码
 *
 * @ClassName ResponseCode
 * @Auther: wangjin
 * @Date: 2022/1/8 18:56
 * @Description: 响应状态码
 * @Version 1.0
 */
public enum ResponseCode {
    SUCCESS(200, "操作成功")
    ,REQUEST_ERROR(400, "请求失败")
    ,SYS_ERROR(500, "服务器未知错误")

    ;

    private Integer code;
    private String  message;

    ResponseCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 获取指定名称的枚举
     *
     * @param name 枚举名
     * @return
     */
    public static ResponseCode getResponseStatus(String name) {
        for (ResponseCode rc : ResponseCode.values()) {
            if (rc.getMessage().equals(name)) {
                return rc;
            }
        }
        return null;
    }
}
